package indi.gao.redis;

import java.io.*;
import java.util.*;

/**
 * <p>Description:</p>
 * <p>Copyright: Copyright (c)2019$</p>
 * <p>Company: Tope</p>
 * <P>Created Date :2019$-08$-09$</P>
 * <P>@version 1.0</P>
 */
class ReplaceIntoSql {
    public static void main(String[] args) throws IOException {
        List<String> result = new ArrayList<>();
        /* 读取数据 */
        BufferedReader studentIDs = new BufferedReader(new InputStreamReader(new FileInputStream(new File("F:\\workSpace\\UtilTest\\TxtReadAndWrite\\src\\main\\file\\st_student_sql.txt")), "UTF-8"));
        String lineTxt;
        String replaceInto;
        while ((lineTxt = studentIDs.readLine()) != null) {//读取每行的数据
            replaceInto = lineTxt.replaceFirst("INSERT", "REPLACE");
            result.add(replaceInto);
        }
        studentIDs.close();

        /* 输出数据 */
        try {
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("E:/ReplaceInsert.txt")),
                    "UTF-8"));

            for (String sqlString : result) {
                bw.write(sqlString);
                bw.newLine();
            }
            bw.close();
        } catch (Exception e) {
            System.err.println("write errors :" + e);
        }
    }

}
